﻿using MetroDataApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MetroDataApi.Controllers
{
    public class QueryDataController : ApiController
    {


        // GET api/querydata/5
        public HttpResponseMessage Get(int prjId, string time, string type)
        {
            using (var db = new MetroDataDataContext())
            {
                var names = db.MonitorPointsDictionary.Where(p => p.PrjId == prjId && p.MonitorType == type).Select(p => p.Name).ToList();
                var data = QueryResults.GetResultsByTime(prjId, time, names);
                return Request.CreateResponse(HttpStatusCode.OK, data);

            }
        }

    }
}
